include Makefile.rules

#
#  project config
#

MMI_RES_DIR := $(strip $(MMI_RES_DIR))

ifneq ($(strip $(JAVA_SUPPORT)), NONE)
SOURCES	 += java_mdu_def.h
endif

SOURCES	 += common_mdu_def.h acc_mdu_def.h alarm_mdu_def.h bt_mdu_def.h camera_mdu_def.h cc_mdu_def.h \
 connection_mdu_def.h dyna_mdu_def.h ebook_mdu_def.h engtd_mdu_def.h eng_mdu_def.h fmm_mdu_def.h fm_mdu_def.h \
 game_boxman_mdu_def.h game_link_mdu_def.h game_manager_mdu_def.h gps_mdu_def.h im_mdu_def.h\
 kuro_mdu_def.h mmibrw_mdu_def.h mms_mdu_def.h mp3_mdu_def.h mpeg4_mdu_def.h multim_mdu_def.h \
 ocr_mdu_def.h pb_mdu_def.h pic_mdu_def.h pic_viewer_mdu_def.h record_mdu_def.h set_mdu_def.h sms_mdu_def.h stk_mdu_def.h \
 streaming_mdu_def.h tp_mdu_def.h vt_mdu_def.h mobiletv_mdu_def.h tv_mdu_def.h qq_mdu_def.h wifi_mdu_def.h

PROJECTS = mmi_res_prj_def.h

ifeq ($(strip $(JAVA_SUPPORT)), IA)
SRCPATH += MS_MMI/source/mmi_app/app/java/ia/h
endif

ifeq ($(strip $(JAVA_SUPPORT)), ESMERTEC_V1)
SRCPATH += MS_MMI/source/mmi_app/app/java/esmertec/h
endif


SRCPATH += MS_MMI/source/mmi_app/app/mms_yr/h MS_MMI/source/mmi_app/app/audio/h MS_MMI/source/mmi_app/app/accessory/h \
 MS_MMI/source/mmi_app/app/cc/h MS_MMI/source/mmi_app/app/cl/h MS_MMI/source/mmi_app/common/h \
 MS_MMI/source/mmi_app/app/menu/h MS_MMI/source/mmi_app/app/multim/h MS_MMI/source/mmi_app/app/pb/h \
 MS_MMI/source/mmi_app/app/phone/h MS_MMI/source/mmi_app/app/setting/h MS_MMI/source/mmi_app/app/sms/h \
 MS_MMI/source/mmi_app/app/ss/h MS_MMI/source/mmi_app/app/stk/h \
 MS_MMI/source/mmi_app/app/eng/h MS_MMI/source/mmi_app/app/mb/h \
 MS_MMI/source/mmi_app/app/envset/h MS_MMI/source/mmi_app/app/msd/h MS_MMI/source/mmi_app/app/mpeg4/h \
 MS_MMI/source/mmi_app/app/udisk/h MS_MMI/source/mmi_app/app/mp3/h MS_MMI/source/mmi_app/app/record/h \
 MS_MMI/source/mmi_app/app/im/h MS_MMI/source/mmi_app/app/wap2.0_yr/h MS_MMI/source/mmi_app/app/fm/h \
 MS_MMI/source/mmi_app/app/ebook/h MS_MMI/source/mmi_app/app/game/game_boxman/h MS_MMI/source/mmi_app/app/camera/h \
 MS_MMI/source/mmi_app/app/game/game_link/h MS_MMI/source/mmi_app/app/game/game_manager/h \
 MS_MMI/source/mmi_app/app/game/game_quintet/h MS_MMI/source/mmi_app/app/game/game_square/h \
 MS_MMI/source/mmi_app/app/idle/h MS_MMI/source/mmi_app/app/connection/h \
 MS_MMI/source/mmi_app/app/im/h MS_MMI/source/mmi_app/app/vt/h MS_MMI/source/mmi_app/app/engtd/h \
 MS_MMI/source/mmi_app/app/block/h MS_MMI/source/mmi_app/app/pic/h \
 MS_MMI/source/mmi_app/app/vcard/h MS_MMI/source/mmi_app/app/fmm/h MS_MMI/source/mmi_app/app/streaming/h \
 MS_MMI/source/mmi_app/app/streaming/h/nex_inc MS_MMI/source/mmi_app/app/im/im_cstar/h \
 MS_MMI/source/mmi_app/app/im/im_t9/h MS_MMI/source/mmi_app/app/streaming/lib MS_MMI/source/mmi_app/app/streaming/nxsys \
 MS_MMI/source/mmi_app/app/streaming/h/nex_inc/nxsys \
 MS_MMI/source/mmi_app/app/gps/h \
 MS_MMI/source/mmi_app/app/tp/h MS_MMI/source/mmi_app/app/ocr/h MS_MMI/source/mmi_app/app/dynamic/h \
 MS_MMI/source/mmi_app/app/bt/h \
 MS_MMI/source/mmi_app/app/theme/h \
 MS_MMI/source/mmi_app/app/kuro/h \
 MS_MMI/source/mmi_app/app/pic_viewer/h \
 MS_MMI/source/mmi_app/app/mobiletv/h \
 MS_MMI/source/mmi_app/app/tv/h \
 MS_MMI/source/mmi_app/app/qq/h \
 MS_MMI/source/mmi_app/app/wifi/h \
 MS_MMI/source/resource \
 MS_MMI/source/resource/$(MMI_RES_DIR)
ifeq ($(strip $(MBM_IMIBASE_SUPPORT)), TRUE)
	SOURCES += imibase_mdu_def.h
	SRCPATH +=  MS_MMI/../../../../dev/imibase/project/spreadtrum/sc6600L/adapter/h

endif


#
#  make process ,don't modify
#

vpath
vpath %.h        $(subst \,/,$(SRCPATH))

SOURCE_OBJ	= $(patsubst %.h, %.source, $(SOURCES))
PROJECT_OBJ	= $(patsubst %.h, %.project, $(PROJECTS))
SOURCE_DIR	= $(patsubst %_mdu_def.h,%, $(SOURCES))
ROOT_DIR	= $(shell $(PERL) ./make/perl_script/get_root_fullpath.pl)

.PHONEY:all
all :builddir macro_create $(SOURCE_OBJ) $(PROJECT_OBJ)
	$(PERL) make/perl_script/resgen.pl "$(ROOT_DIR)/$(BUILD_DIR)/res/$(PROJECTS)" "$(ROOT_DIR)/$(BUILD_DIR)/res/$(MMI_RES_DIR).bin" "$(PERL)"
ifeq ($(strip $(MULTI_THEME_SUPPORT)),TRUE)
	@$(COPY_FILE) $(call Path_process,$(BUILD_DIR)/res/$(MMI_RES_DIR).bin) $(call Path_process,$(BUILD_DIR)/img/)
	@$(COPY_FILE) $(call Path_process,$(BUILD_DIR)/res/$(MMI_RES_DIR)_win.bin) $(call Path_process,$(BUILD_DIR)/img/)
else
	@$(COPY_FILE) $(call Path_process,$(BUILD_DIR)/res/$(MMI_RES_DIR)_DEFAULT.bin)  $(call Path_process,$(BUILD_DIR)/img/$(MMI_RES_DIR).bin)
	@$(COPY_FILE) $(call Path_process,$(BUILD_DIR)/res/$(MMI_RES_DIR)_DEFAULT_win.bin) $(call Path_process,$(BUILD_DIR)/img/$(MMI_RES_DIR)_win.bin)
endif
	@-$(PERL) make/perl_script/rm_dir.pl $(BUILD_DIR)/res ""
	
.PHONEY:builddir
builddir:
	@$(PERL) make/perl_script/mk_dir.pl "build" ""
	@$(PERL) make/perl_script/mk_dir.pl "$(BUILD_DIR)" ""
	@$(PERL) make/perl_script/rm_file.pl $(MMI_RES_DIR).bin $(BUILD_DIR)/img/
	@$(PERL) make/perl_script/rm_file.pl $(MMI_RES_DIR)_win.bin $(BUILD_DIR)/img/
	@$(PERL) make/perl_script/rm_dir.pl res $(BUILD_DIR)/
	@$(PERL) make/perl_script/mk_dir.pl "$(BUILD_DIR)/res" ""
	@$(PERL) make/perl_script/mk_dir.pl "$(BUILD_DIR)/img" ""
	$(COPY_DIR)  $(call Path_process,MS_MMI/source/resource/$(MMI_RES_DIR)/*)  $(call Path_process,$(BUILD_DIR)/res/)
#	attrib -R   $(call Path_process,$(ROOT_DIR)/$(BUILD_DIR)/res/str_table.xls)
#	make\make_cmd\merge.vbs $(call Path_process,$(ROOT_DIR)/$(BUILD_DIR)/res/str_table.xls) $(call Path_process,$(ROOT_DIR)/$(BUILD_DIR)/res/str_table_01.xls)
	@$(PERL) make/perl_script/mk_dir.pl "$(BUILD_DIR)/tmp" ""
	@$(PERL) make/perl_script/mk_dir.pl "$(SOURCE_DIR)" $(BUILD_DIR)/res/

.PHONEY:macro_create
macro_create:
	@make PROJECT=$(PROJECT) -f $(call Path_process,make/pclint/pclint.mk) -k -r -R COMPONENT=app resdep

%_mdu_def.source :%_mdu_def.h
	@$(ECHO) Compiling resource source file $< ...
	@$(ARMCC) -via $(BUILD_DIR)/tmp/app.macro -E $<  -o build/$(PROJECT)_builddir/res/$*/$*_mdu_def.h
	@$(ECHO) $*  build finished

%.project :%.h
	@$(ECHO) Compiling resource project file $< ...
	@$(PERL) make/perl_script/rm_dir.pl $*.h build/$(PROJECT)_builddir/res/
	@$(ARMCC) -via $(BUILD_DIR)/tmp/app.macro -E $<  -o build/$(PROJECT)_builddir/res/$*.h
	@$(ECHO) $*  build finished
	